package com.spring.aop.exposeproxy;

import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.aop.support.JdkRegexpMethodPointcut;
import org.springframework.aop.support.annotation.AnnotationMatchingPointcut;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName InterceptorAnnotationConfig
 * @Description
 * @Author suncx
 * @Date 2020/6/27 14:09
 * @Version 1.0
 */
@Configuration
public class InterceptorAnnotationConfig {
    @Bean
    public DefaultPointcutAdvisor defaultPointcutAdvisor3() {
        MethodInvokeInterceptor interceptor = new MethodInvokeInterceptor();

         AnnotationMatchingPointcut pointcut = new AnnotationMatchingPointcut(ScxMethodInterceptor.class, true);
//        JdkRegexpMethodPointcut pointcut = new JdkRegexpMethodPointcut();
//        pointcut.setPatterns("com.*");

        // 配置增强类advisor
        DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor();
        advisor.setPointcut(pointcut);
        advisor.setAdvice(interceptor);
        return advisor;
    }

}
